package com.jeespring.storage.controller;

import com.jeespring.dto.ResponseDTO;
import com.jeespring.entity.Storage;
import com.jeespring.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.apache.dubbo.config.annotation.Reference;

import java.util.List;

/**
 * @Title: StorageController
 * @Description:
 * @Author 张朝阳
 * @Date 2020/11/29 14:03
 */
@RestController
@RequestMapping("/storage")
@Slf4j
public class StorageController {

    @Reference
    private StorageService storageService;

    @GetMapping("/query")
    List<Storage> query(Storage storage){
        log.info("查询库存：{}",storage.toString());
        return storageService.query(storage);
    }

    @PostMapping("/descstorage")
    ResponseDTO descstorage(@RequestBody Storage storage){
        log.info("扣减库存：{}",storage.toString());
        return storageService.decrStorage(storage);
    }
}
